<?php
// +----------------------------------------------------------------------
// | 用户画像 - 学生或学生家长
// +----------------------------------------------------------------------
namespace app\webapp\model;
use think\Model;
use util\Util;

class Userface extends Model{

    protected $pk = 'id';

    /**
     * 读取对应用户信息
     * @access public
     */
    public function find_student_user($param){
        return $this->table('sp_passport_face_anyang')->where($param)->find();
    }

    /**
     * 增加入库
     */
    public function add_student_user($param){
        $data = [
			'user_id'     => $param['user_id'],
			'face_id'     => $param['face_id'],
			'name'        => $param['name'],
			'work'        => $param['work'],
			'phone'       => $param['phone'],
			'create_time' => time(),
			'update_time' => time(),
        ];
        $rel = self::find_student_user(['user_id' => $param['user_id'],'face_id' => $param['face_id']]);
        if(!$rel){
            return $this->table('sp_passport_face_anyang')->insertGetId($data);
        }else{
            return $param['user_id'];
        }
        
    }
}